}
static const Babl *babl_trc_from_icc (ICC *state, int offset,
- char **error)
+ const char **error)
{
{
int count = icc_read (u32, offset + 8);
icc_write (u32, state->o + 8, 0);
break;
case BABL_TRC_FORMULA_GAMMA:
- icc_allocate_tag (state, name, 14);
- icc_write (sign, state->o, "curv");
- icc_write (u32, state->o + 4, 0);
- icc_write (u32, state->o + 8, 1);
- icc_write (u8f8, state->o + 12, trc->gamma);
- break;
case BABL_TRC_GAMMA_1_8:
- icc_allocate_tag (state, name, 14);
- icc_write (sign, state->o, "curv");
- icc_write (u32, state->o + 4, 0);
- icc_write (u32, state->o + 8, 1);
- icc_write (u8f8, state->o + 12, 1.8);
- break;
case BABL_TRC_GAMMA_2_2:
icc_allocate_tag (state, name, 14);
icc_write (sign, state->o, "curv");
icc_write (u32, state->o + 4, 0);
icc_write (u32, state->o + 8, 1);
- icc_write (u8f8, state->o + 12, 2.2);
+ icc_write (u8f8, state->o + 12, trc->gamma);
break;
case BABL_TRC_LUT:
icc_allocate_tag (state, name, 13 + trc->lut_size * 2);
}
const Babl *
-babl_space_from_icc (const char *icc_data,
- int icc_length,
- char **error)
+babl_space_from_icc (const char *icc_data,
+ int icc_length,
+ const char **error)
{
ICC *state = icc_state_new ((char*)icc_data, icc_length, 0);
int profile_size = icc_read (u32, 0);
const Babl *trc_red = NULL;
const Babl *trc_green = NULL;
const Babl *trc_blue = NULL;
+ const char *int_err;
char *descr = NULL;
char *copyright = NULL;
sign_t profile_class, color_space;
+ if (!error) error = &int_err;
+ *error = NULL;
+
if (profile_size != icc_length)
{
*error = "icc profile length inconsistency";
/**
* babl_space_from_icc:
*
+ * @icc_data: pointer to icc profile in memory
+ * @icc_length: length of icc profile in bytes
+ " @error: pointer to a string where decoding errors can be stored,
+ * if an error occurs, NULL is returned and an error message
+ * is provided in error.
+ *
* Create a babl space from an in memory ICC profile, the
* profile does no longer need to be loaded for the space to work,
* multiple calls with the same icc profile will result in the
* same space.
*
- * For now, limited to v2 ICC profiles, support for v4 profiles will be added.
- *
- * babl uses internal parametric TRCs when the provided LUTs are sufficiently
- * similar.
- *
* If a BablSpace cannot be created from the profile NULL is returned and
* a static string is set on the provided error location.
*/
-const Babl *babl_space_from_icc (const char *icc_data,
- int icc_length,
- char **error);
+const Babl *babl_space_from_icc (const char *icc_data,
+ int icc_length,
+ const char **error);
/* babl_space_to_icc:
*
* Creates an ICCv2 RGB matrix profile for a babl space. The profiles strive to
* be as small and compact as possible, TRCs are stored as 1024 entry LUT(s).
+ *
+ * you should make a copy of the profile before making another call to this
+ * function.
*/
const char *babl_space_to_icc (const Babl *space, int *icc_length);